import * as fs from "fs";
import fetch from "node-fetch";
export const downloadImage = async (url: string, local_path: string) => {
  try {
    console.log(url);
    const response = await fetch(url);
    const buffer = await response.buffer();
    fs.writeFileSync(local_path, buffer);
    return true;
  } catch (error) {
    console.error("Failed to download image:", error);
  }
  return false;
};

export const unlinkFile = (path: string) => {
  fs.unlink(path, (err) => {
    console.error(err);
  });
};
